/*
 * uncompressor.cpp
 *
 *  Created on: 2009-1-7
 *      Author: fanliangliang
 */

#include "uncompressor.h"
#include "file_deleter.h"
#include "common_struct.h"

using namespace toxic;

Uncompressor::Uncompressor() {

}

Uncompressor::~Uncompressor() {

}

void Uncompressor::process(FileArgument* arg) {
	if (arg == 0) {
		xerror << "null pointer {arg}, at {void Uncompressor::process(FileArgument* arg)}";
		return;
	}

	if (arg->isCompressed) {
		xtrace << "start uncompressing {" << arg->name << "}";
		string target = arg->destination + arg->name;
		if (uncompress(target, arg->destination)) {
			xtrace << "finish uncompressing {" << arg->name << "}, saving at {" << arg->destination << "}";
			FileDeleter::instance()->releaseFile(target, 1);
		}
	}
	else {
		xtrace << "no need to uncompress {" << arg->name << "}";
	}

	delete arg;
}
